using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace VotingSystem.Models
{
    public class VoteOption
    {
        [Key]
        public int Id { get; set; }

        [Required]
        public int VoteId { get; set; }

        [Required]
        [StringLength(100)]
        public string Title { get; set; } = string.Empty;

        [StringLength(500)]
        public string? Description { get; set; }

        [StringLength(500)]
        public string? ImageUrl { get; set; }

        public int Votes { get; set; }

        public int? MaxRating { get; set; }

        [StringLength(100)]
        public string? RatingDescription { get; set; }

        public long TotalRating { get; set; }

        public double AverageRating { get; set; }

        [ForeignKey("VoteId")]
        public Vote? Vote { get; set; }

        public virtual ICollection<VoteRecord> Records { get; set; } = new List<VoteRecord>();

        [NotMapped]
        public int VoteCount => Records.Count;

        [NotMapped]
        public double Percentage => Vote.TotalVotes == 0 ? 0 : (double)VoteCount / Vote.TotalVotes * 100;

        public int Order { get; set; }

        public bool IsCorrect { get; set; }

        public string? Explanation { get; set; }
    }
} 